## python 中的异步

'''
import time
def func1(name):
    print(f"将{name}放进锅里")
    time.sleep(5)
    print(name,"已完成")


for i in ["回锅肉", "鱼香肉丝", "地三鲜"]:
    func1(i)
'''

import asyncio
async def func1(name):
    print(f"将{name}放进锅里")
    # 如果这个过程耗时比较长，那么让他在这里自己运行，主线程返回
    await asyncio.sleep(5)
    print(name,"已完成")

async def func2():
    # names = []
    # for i in ["回锅肉", "鱼香肉丝", "地三鲜"]:
    #     names.append(func1(i))
    t1 = asyncio.create_task(func1("回锅肉"))
    t2 = asyncio.create_task(func1("鱼香肉丝"))
    t3 = asyncio.create_task(func1("地三鲜"))
    await t1
    await t2
    await t3

asyncio.run(func2())